<?php  
/*
$Id$
*/


if (!defined('BASEPATH')) exit('No direct script access allowed');

class Fixcover extends Controller {

	function Fixcover()
	{
		parent::Controller();
	}
	
	
	function index()
	{
		
	}

	function fix($start = 0)
	{
		$this->db->limit(50, $start);
		
		$query = $this->db->get('album_categories');
		
		if($query->num_rows() > 0)
		{
			
			foreach ($query->result_array() as $row)
			{
				$this->db->select('s');
				$this->db->limit(1);
				$this->db->where('aid', $row['aid']);
				$query2 = $this->db->get('album_images');
				if($query2->num_rows() > 0)
				{
					$row2 = $query2->row_array();
					$this->db->set('cover' , $row2['s']);
					$this->db->where('aid' , $row['aid']);
					$this->db->update('album_categories');
				}
			}
			$this->cache->remove_group('album_list');
			$start = $start + 50;
			redirect('album/fixcover/fix/' . $start, 'refresh');
		}
		else
		{
			echo "Done!";
		}
	}
	
}